|
|
|
|
|
|
|
program uses to access the database. Learning to use SQL is like learning any other programming language. SQL was created and designed so that when you learn how to use it, you can access any database that supports SQL access. Just as Visual Basic conforms to standards and each command or statement has a certain syntax, so does SQL. SQL is actually divided into two types of statements: |
|
|
|
|
|
|
|
|
One used to define the database itself is called data-definition language (DDL). |
|
|
|
|
|
|
|
|
The other, used to access the database, is called data-manipulation language (DML). |
|
|
|
|
|
|
|
|
This section covers a short discussion of the DML SQL language. |
|
|
|
|
|
|
|
|
SQL statements allow you to perform processing in one line or a few lines of SQL code that would take you many lines of BASIC code to do. SQL statements create queries that define the fields, tables, and range of records needed in a particular process. When a query is processed, the data is usually returned in a dynaset. A dynaset is an updatable recordset that contains a collection of pointers to the data. SQL statements consist of the following three sections: |
|
|
|
|
|
|
|
|
Parameter declarations are optional parameters passed by the program code to the SQL statement. |
|
|
|
|
|
|
|
|
Manipulative statements tell the database engine what kind of process it will perform. |
|
|
|
|
|
|
|
|
Options declarations define and filter conditions, groupings, or sorts that need to be applied to the data being processed. |
|
|
|
|
|
|
|
|
The syntax for a SQL statement is as follows: |
|
|
|
|
|
|
|
|
[Parameters] Manipulative statement [Options] |
|
|
|
|
|
|
|
|
In this section, you'll review some of the manipulative statements and a few of the options that you can use. SQL statements can perform a wide variety of tasks. These mirror the actions that users would need to perform on their data. These actions fall into one of five distinct manipulative statements: |
|
|
|
|
|
|
|
|
SELECT is used to retrieve a group of records from the database and places them into a dynaset. |
|
|
|
|
|
|
|
|
INSERT INTO adds a group of records to a table. |
|
|
|
|
|
|
|
|
UPDATE updates the values in a table. |
|
|
|
|
|
|
|
|
DELETE FROM removes the specified records from the database. |
|
|
|
|
|
|
|
|
TRANSFORM creates a new summary table by using the contents of one field as the names of the columns. |
|
|
|
|
|